/**
 * Description: 登录Api
 *
 * Created by hrx on 2023/9/18
 */
import service, {IResponse, IResponseArrayDto, IResponseDto} from "@/utils/ajax";
import {AxiosResponse} from "axios";
export interface loginParams {
  userAccount: string,
  password: string,
  merchantCode: number
}

export function loginApi(data: loginParams): Promise<IResponse> {
  return service({
    url: '/cloud/login',
    method: "post",
    data,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
      "showLoading": true
    },
  })
}

export interface userInfoDTO<T>{
  merchantName?: string,
  merchantCode?: string,
  userName?: string,
  userType?: number,
  oneselfImage?: string,
  workPermitImage?: string,
  authorities?: Array<T>
}

export interface authoritiesDTO{
  authority: string
}

// 用户信息
export function getUserInfoApi(): Promise<AxiosResponse<IResponseDto<userInfoDTO<authoritiesDTO>>>> {
  return service({
    url: '/cloud/user/findCurrentUserInfo',
    method: "post",
    data: {},
    headers: {
      "showLoading": true
    },
  })
}
